#!coding=utf-8
import time
import threading

# 创建事件对象
event = threading.Event()

def waiter(event):
    print(threading.current_thread().name + " Waiting for the event to be set...")
    event.wait()
    print(threading.current_thread().name + " Event has been set, resuming...")

def setter(event):
    print(threading.current_thread().name + " Sleeping for 3 seconds before setting event...")
    time.sleep(3)
    event.set()

# 创建并启动线程
thread1 = threading.Thread(target=waiter, args=(event,))
thread2 = threading.Thread(target=setter, args=(event,))

thread1.start()
thread2.start()

# 等待线程完成
thread1.join()
thread2.join()
